import {defineStore} from "pinia";
import {computed, ref} from "vue";

export const useTokenStore = defineStore("token", () => {
    const token = ref(null);
    const tokenStr = computed(() => {
        return token.value;
    });

    function update(tk) {
        token.value = tk;
    }

    function $reset() {
        token.value = null;
    }

    return {token, tokenStr, update, $reset};
},{
    persist:{
        key:'token',
        storage:sessionStorage,
        paths:['token']
    }
});